﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:src="clr-namespace:NielsHebling.UnitTestResultViewerForSL.Controls"    
    xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0">

    <!--TODO: To be moved to generic_Styles-->
    <!--Extended ListView SortArrows-->
    <DataTemplate x:Key="HeaderTemplateArrowUp">
        <DockPanel>
            <TextBlock HorizontalAlignment="Center" Text="{Binding}"/>
            <Path x:Name="arrow" StrokeThickness = "1" Fill = "Gray" Data = "M 5,10 L 15,10 L 10,5 L 5,10"/>
        </DockPanel>
    </DataTemplate>

    <DataTemplate x:Key="HeaderTemplateArrowDown">
        <DockPanel>
            <TextBlock HorizontalAlignment="Center" Text="{Binding}"/>
            <Path x:Name="arrow" StrokeThickness = "1" Fill = "Gray" Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
        </DockPanel>
    </DataTemplate>

    <DataTemplate x:Key="HeaderTemplateUnsorted">
        <DockPanel>
            <TextBlock HorizontalAlignment="Center" Text="{Binding}"/>
            <Path x:Name="arrow" StrokeThickness = "1" Fill = "Transparent" Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
        </DockPanel>
    </DataTemplate>

    <ControlTemplate x:Key="ArrowDown">
        <DockPanel>
            <Path x:Name="arrow" StrokeThickness = "1" Fill = "Gray" Data = "M 5,5 L 10,10 L 15,5 L 5,5"/>
        </DockPanel>
    </ControlTemplate>

    <!--ListViewStyle-->
    <Style TargetType="{x:Type ListViewItem}" x:Key="ListViewItemStyleBase">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListViewItem}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}">
                        <StackPanel>
                            <GridViewRowPresenter Name="row"/>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--Alternating Row Styles-->
    <Style TargetType="{x:Type ListViewItem}" 
               BasedOn="{StaticResource ListViewItemStyleBase}" 
               x:Key="ListViewItemStyle1">
        <Setter Property="Background" Value="White"/>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Background" Value="#FFFFC120"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="#FFE3E3E3"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type ListViewItem}" 
               BasedOn="{StaticResource ListViewItemStyleBase}" 
               x:Key="ListViewItemStyle2">
        <Setter Property="Background" Value="AliceBlue"/>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Background" Value="#FFFFC120"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="#FFE3E3E3"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    <src:ListViewItemStyleSelector x:Key="ListViewItemStyleSelector"/>

    <!--Vertical separator line-->
    <Style x:Key="SeparatorStyle"
           TargetType="{x:Type Border}">
        <Setter Property="BorderThickness" Value="1,0,0,0"/>
        <Setter Property="BorderBrush" Value="#FFC5C5C5"/>
        <Setter Property="Margin" Value="5,0,5,0"/>
        <Setter Property="Width" Value="2"/>
        <Setter Property="Background" Value="White"/>
    </Style>
    
    <Style TargetType="{x:Type src:ResultList}">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>        
        <Setter Property="Background" Value="Black"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type src:ResultList}">
                    <Grid x:Name="LayoutRoot">
                        <DockPanel LastChildFill="True">
                            <DockPanel DockPanel.Dock="Top" Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolboxHeadingAccentKey}}">
                                <StackPanel DockPanel.Dock="Left" Orientation="Horizontal" Margin="2" VerticalAlignment="Center">
                                    <ToggleButton x:Name="PART_ToggleShowSucceeded"                                                   
                                                  Background="{DynamicResource {x:Static vsfx:VsBrushes.ButtonFaceKey}}"
                                                  Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ButtonTextKey}}"
                                                  Tag="Passed" Margin="2,0,0,0">
                                        <ToggleButton.Content>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="/UnitTestResultViewerForSL;component/Themes/Images/passed16.png" Width="16"/>
                                                <TextBlock Text="{TemplateBinding ToggleShowSuccessText}" Margin="3,0,0,0" VerticalAlignment="Center"/>
                                            </StackPanel>
                                        </ToggleButton.Content>
                                    </ToggleButton>
                                    <ToggleButton x:Name="PART_ToggleShowFailed" 
                                                  Background="{DynamicResource {x:Static vsfx:VsBrushes.ButtonFaceKey}}"
                                                  Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ButtonTextKey}}"
                                                  Tag="Failed" Margin="2,0,0,0">
                                        <ToggleButton.Content>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="/UnitTestResultViewerForSL;component/Themes/Images/fail16.png" Width="16"/>
                                                <TextBlock Text="{TemplateBinding ToggleShowFailedText}" Margin="3,0,0,0" VerticalAlignment="Center"/>
                                            </StackPanel>
                                        </ToggleButton.Content>
                                    </ToggleButton>
                                    <ToggleButton x:Name="PART_ToggleShowIgnored" 
                                                  Background="{DynamicResource {x:Static vsfx:VsBrushes.ButtonFaceKey}}"
                                                  Foreground="{DynamicResource {x:Static vsfx:VsBrushes.ButtonTextKey}}"
                                                  Tag="Ignored" Margin="2,0,0,0">
                                        <ToggleButton.Content>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="/UnitTestResultViewerForSL;component/Themes/Images/ignored16.png" Width="16"/>
                                                <TextBlock Text="{TemplateBinding ToggleShowIgnoredText}" Margin="3,0,0,0" VerticalAlignment="Center"/>
                                            </StackPanel>
                                        </ToggleButton.Content>
                                    </ToggleButton>
                                </StackPanel>                                
                                <StackPanel DockPanel.Dock="Right" HorizontalAlignment="Right" Orientation="Horizontal" Margin="2">
                                    <!--<Label Content="{TemplateBinding LabelFilterByTagText}"/>
                                    <ComboBox>
                                        <ComboBoxItem Content="All Tags" IsSelected="True"/>
                                        <ComboBoxItem/>
                                        <ComboBoxItem/>
                                    </ComboBox>-->
                                    <Button x:Name="PART_ButtonRunTest" VerticalAlignment="Center">
                                        <Button.Content>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="/UnitTestResultViewerForSL;component/Themes/Images/arrow16.png" MaxHeight="16" Margin="2,0,0,0"/>
                                                <TextBlock Text="{TemplateBinding ButtonRunTestText}"/>
                                            </StackPanel>
                                        </Button.Content>
                                    </Button>
                                </StackPanel>
                                <StackPanel DockPanel.Dock="Right" HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Center">
                                    <Label Content="{TemplateBinding LabelFilterByAssemblyText}"/>
                                    <ComboBox x:Name="PART_ComboBoxAssemblies" ItemsSource="{TemplateBinding AssemblyItems}" MinWidth="150" VerticalAlignment="Center">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <ContentPresenter>
                                                    <ContentPresenter.Content>
                                                        <TextBlock Text="{Binding Path=ProjectName}" VerticalAlignment="Center"/>
                                                    </ContentPresenter.Content>
                                                </ContentPresenter>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                    <Button x:Name="PART_ButtonRefreshAssemblies" ToolTip="{TemplateBinding ButtonRefreshAssembliesText}" VerticalAlignment="Center" Margin="2,0,0,0">
                                        <Button.ContentTemplate>
                                            <DataTemplate>
                                                <Image Source="/UnitTestResultViewerForSL;component/Themes/Images/refresh16.png" MaxHeight="16"/>
                                            </DataTemplate>
                                        </Button.ContentTemplate>
                                    </Button>
                                </StackPanel>
                            </DockPanel>
                            
                            <!--Bottom-->
                            <DockPanel DockPanel.Dock="Bottom" Background="{DynamicResource {x:Static vsfx:VsBrushes.ToolboxHeadingAccentKey}}">
                                <!--<Label x:Name="PART_LabelTotalTestResultsInfo" DockPanel.Dock="Left" Content="{TemplateBinding LabelTestRunSummaryText}"/>-->
                                <ProgressBar x:Name="PART_ProgresBarRunningState" DockPanel.Dock="Right" HorizontalAlignment="Right" Value="{TemplateBinding ProgressValue}" Minimum="0" Maximum="{TemplateBinding MaxProgressValue}" IsEnabled="True" Width="100" Margin="2" SmallChange="1" Visibility="Hidden"/>
                                <!--<CheckBox x:Name="PART_CheckBoxRunOnBuildDone" DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Center" Content="{TemplateBinding CheckBoxRunOnBuildDoneText}" IsChecked="{TemplateBinding RunOnBuildDone}"/>-->
                            </DockPanel>
                            
                            <!--List-->
                            <src:ExtendedListView ItemsSource="{TemplateBinding Items}">                                
                                <src:ExtendedListView.View>
                                    <GridView ColumnHeaderTemplate="{StaticResource HeaderTemplateUnsorted}">
                                        <src:ExtendedGridViewColumn x:Name="PART_ColumnTestStatusIcon" SortProperty="Result">
                                            <src:ExtendedGridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                    <Image x:Name="cellImage" Width="14"/>
                                                    <DataTemplate.Triggers>
                                                        <DataTrigger Binding="{Binding Path=Result}" Value="Passed">
                                                            <Setter TargetName="cellImage" Property="Source" Value="/UnitTestResultViewerForSL;component/Themes/Images/passed16.png"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Path=Result}" Value="Failed">
                                                            <Setter TargetName="cellImage" Property="Source" Value="/UnitTestResultViewerForSL;component/Themes/Images/fail16.png"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Path=Result}" Value="Ignored">
                                                            <Setter TargetName="cellImage" Property="Source" Value="/UnitTestResultViewerForSL;component/Themes/Images/ignored16.png"/>
                                                        </DataTrigger>
                                                    </DataTemplate.Triggers>                                                    
                                                </DataTemplate>
                                            </src:ExtendedGridViewColumn.CellTemplate>
                                        </src:ExtendedGridViewColumn>
                                        <src:ExtendedGridViewColumn x:Name="PART_ColumnTestStatus" Header="Status" DisplayMemberBinding="{Binding Path=Result}" SortProperty="Result"/>
                                        <src:ExtendedGridViewColumn x:Name="PART_ColumnTestMessage" Header="Message" DisplayMemberBinding="{Binding Path=Message}" SortProperty="Message"/>
                                        <src:ExtendedGridViewColumn x:Name="PART_ColumnTestSource" Header="Source" DisplayMemberBinding="{Binding Path=Method}" SortProperty="Method"/>
                                        <src:ExtendedGridViewColumn x:Name="PART_ColumnTestDuration" Header="Duration" DisplayMemberBinding="{Binding Path=Duration}" SortProperty="Duration"/>
                                    </GridView>
                                </src:ExtendedListView.View>
                            </src:ExtendedListView>
                        </DockPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>